#include "../logs/log.h"

void test_log()
{
    DEBUG("%s", "测试开始！");
    // logs::logger::ptr logger = logs::LoggerManager::getInstance().get_Logger("async_logger");
    logs::logger::ptr logger = logs::getLogger("async_logger");
    logger->debug("%s", "异步日志器测试...");
    logger->info("%s", "异步日志器测试...");
    logger->warn("%s", "异步日志器测试...");
    logger->error("%s", "异步日志器测试...");
    logger->fatal("%s", "异步日志器测试...");
    size_t sz = 0;
    while (sz < 1024 * 1024 * 10)
    {
        logger->fatal("%s", "异步日志器测试...");
        sz += 80;
    }
    DEBUG("%s", "测试结束！");

    // DEBUG("%s", "异步日志器测试...");
    // INFO("%s", "异步日志器测试...");
    // WARN("%s", "异步日志器测试...");
    // ERROR("%s", "异步日志器测试...");
    // FATAL("%s", "异步日志器测试...");
    // size_t cnt = 0;
    // while (cnt < 500000)
    // {
    //     FATAL("%s - %d", "异步日志器测试...", cnt++);
    // }
}
int main()
{
    // 可自定义创建日志器，定义日志器的输出
    std::unique_ptr<logs::LoggerBuilder> builder = std::make_unique<logs::GlobalLoggerBuild>();
    builder->BuilderLoggerType(logs::LoggerType::LOGGER_ASYNC);
    builder->BuilderLoggerName("async_logger");
    builder->BuilderLoggerLevel(logs::LogLevel::Value::WARN);
    // builder->BuilderLoggerFormatter("%m%n");
    // builder->buildSink<logs::StdoutSink>();
    builder->buildSink<logs::RollBySizeSink>("./aa/test.log", 1024 * 1024);
    // builder->BuilderEnableUnsafeAsync();
    builder->build();
    test_log();
    return 0;
}